package com.fastshopping.order.service.impl;

import com.fastshopping.order.dao.OrderMapper;
import com.fastshopping.order.pojo.Order;
import com.fastshopping.order.service.OrderService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wink.entity.PageResult;
import com.wink.entity.QueryPageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;
import java.util.Map;

/**
 * @Name: 李袁勇
 * @Date: 2020/6/2 16:35
 * @Version: 1.0
 **/

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public PageResult findAll(QueryPageBean queryPageBean, Order order) {
        PageHelper.startPage(queryPageBean.getCurrentPage(), queryPageBean.getPageSize());
        String queryString = queryPageBean.getQueryString();
        String time1 = null;
        String time2 = null;
        if(queryString != null){
            String[] split = queryString.split(" ");
            time1=split[0];
            time2=split[1];
        }
        System.out.println(order);
        Page<Order> byAll = orderMapper.findByAll(order.getId(),order.getReceiver_mobile(),order.getDelivery(),time1,time2,order.getConsign_status());
        return new PageResult(byAll.getTotal(),byAll.getResult());
    }

    @Override
    public List<Map> findCount() {
        return orderMapper.findCount();
    }

    @Override
    public Order findOneOrder(int id) {
        return orderMapper.findOneOrder(id);
    }

    @Override
    public void updateById(int id) {
        orderMapper.updateById(id);
    }

    @Override
    public void deliverGoods(int id) {
        orderMapper.deliverGoods(id);
    }

    @Override
    public void takeGoods(int id) {
        orderMapper.takeGoods(id);
    }

    @Override
    public void confirmReceipt(int id) {
        orderMapper.confirmReceipt(id);
    }
}
